<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true" style="height:40px;">
        <el-form-item label="任务名称" prop="taskName">
            <el-input
            v-model="queryParams.taskName"
            placeholder="请输入任务名称"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
            />
        </el-form-item>
       
        <el-form-item>
            <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
        
    </el-form>
    
    <el-table v-loading="loading" border :data="list"  >
        <el-table-column label="流程名称" prop="processInstanceName" :show-overflow-tooltip="true"   />
        <el-table-column label="任务名称" prop="name" :show-overflow-tooltip="true"   />
        <el-table-column label="开始时间" prop="startTime" align="center" width="165px">
            <template slot-scope="scope"><span>{{ scope.row.createTime }}</span></template>
        </el-table-column>
        <el-table-column label="结束时间" prop="endTime" align="center" width="165px">
            <template slot-scope="scope"><span>{{ scope.row.endTime }}</span></template>
        </el-table-column>
        <el-table-column label="所有人" prop="owner" align="center">
            <template slot-scope="scope"><span>{{ scope.row.owner }}</span></template>
        </el-table-column>
        <el-table-column label="执行人" prop="assignee" align="center">
            <template slot-scope="scope"><span>{{ scope.row.assignee }}</span></template>
        </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="{row}">
            <el-dropdown>
                <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item icon="el-icon-view" @click.native="btnView(row.processInstanceId)">查看详情
                    </el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
     <process-detail v-if="dialogViewVisible" :visible.sync="dialogViewVisible"
                        :processInstanceId="processInstanceId"></process-detail>
        <execute-task v-if="dialogExcuteTaskVisible" :visible.sync="dialogExcuteTaskVisible"
    :executeTaskId="executeTaskId" @executeTaskFinished="list"></execute-task>
  </div>
</template>

<script>
import { list } from "@/api/flowable/task";
import {Message} from 'element-ui'
import ProcessDetail from "../components/ProcessDetail";
import ExecuteTask from '../components/ExecuteTask'
export default {
  name: "model",
  components:{
    ProcessDetail,
    ExecuteTask
  },
  data() {
    return {
      dialogExcuteTaskVisible:false,
      executeTaskId:undefined,
      dialogViewVisible:false,
      processInstanceId:undefined,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  computed: {
        user: {
            get() {
                return this.$store.state.user.user
            }
        }
    },
  created() {
      console.log(this.user)
      this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      list(this.queryParams).then(
        response => {
          this.list = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
    },
    btnView(processInstanceId) {
        this.processInstanceId = processInstanceId
        this.dialogViewVisible = true
    }
  }
};
</script>